package sonic.game.character;

import sonic.game.Game;
import sonic.game.animation.Animation;
import sonic.game.animation.AnimationSet;
import sonic.game.tile.Fireball;
import sonic.game.tile.Tile;
import sonic.game.util.Vector2D;

/**
 * Wasp Badnik
 * 
 * A flying, fireball-launching pest
 * 
 * @author Richard Greenlees
 *
 */

public class WaspBadnik extends Badnik {

	
	
	public WaspBadnik(Vector2D startLoc) {
		super(startLoc);
		AnimationSet normalAnims = new AnimationSet();
		normalAnims.addAnimation("standAnim", new Animation(0, false, "Characters/Badniks/wasp_stand_1.png"));
		normalAnims.addAnimation("moveAnim", new Animation(0.5f, true, "Characters/Badniks/wasp_stand_1.png"));
		normalAnims.addAnimation("shootAnim", new Animation(0.5f, true, "Characters/Badniks/wasp_shoot_1.png"));
		normalAnims.setCurrentAnimation("standAnim");

		addAnimationSet("normalAnims", normalAnims);
		setCurrentAnimSet("normalAnims");

		collisionBoxX = 45.0f;
		collisionBoxY = 32.0f;
		
		physicsType = ePhysicsType.PHYS_FLYING;

		maxGroundSpeed = 120.0f;
		fireRate = 2.0f;
		timeToFire = 0.5f;
	}
	
	public void shootAt(Tile target)
	{
		@SuppressWarnings("unused")
		// Subtract the vectors to get the direction, normalise and the
		Fireball proj = new Fireball(location, Vector2D.normalise(Vector2D.vectorSubtract(target.getCentre(), location)), 150.0f);
	}
	
	public void aiUpdate(double deltaTime)
	{
		super.aiUpdate(deltaTime);
		// Chase the player to ensure it's always within 275 pixels of the player
		if (Vector2D.vSize(Vector2D.vectorSubtract(Game.player.getCentre(), location)) > 275.0f && !bPendingFire)
		{
			desiredDirection = (Game.player.location.x < location.x) ? -1 : 1;
		}
	}

}
